﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Heroius.Extension;
using Heroius.Extension.WPF;

namespace DocWaterMarker
{
    public class OpContext : ObservableEntity
    {
        [PropertyPanel(Label = "PDF文件", MatchKey = "Common")]
        public ObservableCollection<FileNameText> Files { get; set; } = new ObservableCollection<FileNameText>();

        [PropertyPanel(Label = "水印文字", Order = 2, MatchKey = "Watermark")]
        public ObservableCollection<WatermarkText> WaterMarks { get; set; } = new ObservableCollection<WatermarkText>() { "IEPI", "因斯福", "客户名" };
        [PropertyPanel(Label = "图像DPI", Order = 3, MatchKey = "Watermark")]
        public int DPI { get { return _DPI; } set { _DPI = value; RaisePropertyChangedEvent("DPI"); } } int _DPI = 130;
        [PropertyPanel(Label = "透明度(0-100)", Order = 4, MatchKey = "Watermark")]
        public int Alpha { get { return _Alpha; } set { _Alpha = value; RaisePropertyChangedEvent("Alpha"); } } int _Alpha = 30;
        [PropertyPanel(Label = "字号", Order = 5, MatchKey = "Watermark")]
        public float FontSize { get { return _FontSize; } set { _FontSize = value; RaisePropertyChangedEvent("FontSize"); } } float _FontSize = 20f;
        [PropertyPanel(Label = "纵向间隔系数", Order = 6, MatchKey = "Watermark")]
        public float VFactor { get { return _VFactor; } set { _VFactor = value; RaisePropertyChangedEvent("VFactor"); } } float _VFactor = 1.5f;
        [PropertyPanel(Label = "横向间隔系数", Order = 7, MatchKey = "Watermark")]
        public float HFactor { get { return _HFactor; } set { _HFactor = value; RaisePropertyChangedEvent("HFactor"); } } float _HFactor = 0.8f;
        [PropertyPanel(Label ="中间图片格式", Order = 8, MatchKey = "Watermark")]
        public InterFormat InterFormat { get { return _InterFormat; } set { _InterFormat = value; RaisePropertyChangedEvent("InterFormat"); } } InterFormat _InterFormat = InterFormat.JPG;
        //todo: sign
        [PropertyPanel(Label = "签名文件", Order = -90, MatchKey = "Sign"), DataType("File")]
        public string Sign { get; set; } = string.Empty;
    }

    public class FileNameText
    {
        [DataType("File"), PropertyPanel(Label = "文件"), PropertyPanelFileAttribute(Filter = "PDF 文件|*.pdf")]
        public string File { get; set; } = string.Empty;

        public static implicit operator FileNameText(string text)
        {
            return new FileNameText() { File = text };
        }
    }

    public class WatermarkText
    {
        [PropertyPanel(Label = "值")]
        public string Text { get; set; }

        public static implicit operator WatermarkText(string text)
        {
            return new WatermarkText() { Text = text };
        }
    }
}
